<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<html>
<head>
	<meta charset="UTF-8">
	<title>入库列表</title>
	<meta name="viewport" content="width=360,height=640,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link rel="stylesheet" href="<%=basePath%>/css/pda/loginPda.css" />
	<link rel="stylesheet" href="<%=basePath%>/css/pda/pop.css" />
	<link href="<%=basePath%>/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
</head>
<style>
	body, html{
		width:100%;height:100%;
	}
	#query{
	border:none;
	color:#fff;
	background:#1ba2e3;
		height:36px;
		padding:0 5px;
		border-radius:0 4px 4px 0;
		position:relative;
		left:-2px;
	}
	#purchaseOrderId{
		border:1px solid #ddd;
		height:36px;
		border-radius:4px 0 0 4px;
	}


</style>
<body>
<div class="pdaHead">
	<a href="<%=basePath%>/web/main"><img src="<%=basePath%>/img/pda/arrow_back.png" alt="" /></a>
	<span>商品入库</span>
</div>
<div class="pdaContent">
	<div class="baseInfo">供货单基本信息</div>
	<div class="listInfo">
		<span>供货单编码：</span>
		<span style="display: inline-block;margin-bottom:8px;"><input type="text" id="purchaseOrderId" name="purchaseOrderId" value="${requestScope.invInputHeadCO.inputHeadCode}"><input type="button"  id="query" onclick="querySupply_Mterial()" value="刷新"/></span>
	</div>
	<div class="listInfo">
		<span>供应商名称：</span>
		<span id="vendorName"></span>
	</div>

	<div class="listInfo">
		<span>总计金额：</span>
		<span id="price"></span>
	</div>
	<div class="listInfo">
		<span>应供货日期：</span>
		<span id="sendDate"></span>
	</div>

	<!--列表-->
	<div class="tableList" style="margin-top:30px;">
		<div class="baseInfo">物资明细</div>
		<table cellspacing="0" border="1">
			<tr>
				<td class="serialnums">序号</td>
				<td class="materialCode">物料编码</td>
				<td class="materialName">物料名称</td>
				<td class="volume">应入库量</td>
				<td class="operation">操作</td>
			</tr>
			<tbody  id="materialTable"></tbody>
		</table>


	</div>
</div>
</body>
<script src="<%=basePath%>/css/bootstrap-3.3.7/js/jquery-2.1.4.min.js" type="text/javascript" charset="utf-8"></script>
<script src="<%=basePath%>/css/bootstrap-3.3.7/js/bootstrap.js" type="text/javascript" charset="utf-8"></script>
<script src="<%=basePath%>/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="<%=basePath%>/js/redragon.js" type="text/javascript" charset="utf-8"></script>
<script>
    //var queryDataFlg="";
    $(function(){
        $("#purchaseOrderId").focus();
	});
    function querySupply_Mterial(){
        if($("#purchaseOrderId").val()==""){
            redragonJS.alert("请输入供货单编号!");
            //$("#purchaseOrderId").focus();
            return;
		}
        let sub = {};
        sub.supplyMaterialId = $("#purchaseOrderId").val();
        $.ajax({
            url : "<%=basePath%>/web/invInputPda/getSupplyMaterialData",
            contentType : "application/json",
            dataType : 'json',
            data : JSON.stringify(sub),
            type:'post',
            async : false,
            success: function (data) {
                if(data.code == 0) {
                    $("#purchaseOrderId").html(data.supplyMaterial.purchase_order_id);
                    $("#vendorName").html(data.supplyMaterial.vendor_name);
                    $("#price").html(fmoney(data.supplyMaterial.price,2)+"元");
                    $("#sendDate").html(data.supplyMaterial.send_time);
                    var html="";
                    $("#materialTable").html("");
                    if(data.supplyMaterialDetailList.length>0){
						for(var i=0;i<data.supplyMaterialDetailList.length;i++){
							html+="<tr>"
							 html+="<td>"+(i+1)+"</td>"
							 html+="<td>"+data.supplyMaterialDetailList[i]["material_code"]+"</td>"
							 html+="<td>"+data.supplyMaterialDetailList[i]["material_name"]+"</td>"
							 html+="<td>"+data.supplyMaterialDetailList[i]["num"]+"</td>"
							 html+="<td class='ruku'><span><a href='<%=basePath%>/web/invInputPda/goSupplyMaterialDetail?supplyMaterialId="+data.supplyMaterial.purchase_order_id+"&id="+data.supplyMaterialDetailList[i]["id"]+"'>入库</a></span></td>"
							 html+="</tr>"
						}
                        $("#materialTable").append(html);
					}
                } else {
                    redragonJS.alert(data.msg);
                }
                //window.clearInterval(queryDataFlg);
            }
        });
	}
    //格式化金额
    function fmoney(s, n)
    {
        n = n > 0 && n <= 20 ? n : 2;
        s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";//更改这里n数也可确定要保留的小数位
        var l = s.split(".")[0].split("").reverse(),
            r = s.split(".")[1];
        t = "";
        for(i = 0; i < l.length; i++ )
        {
            t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");
        }
        return t.split("").reverse().join("") + "." + r.substring(0,2);//保留2位小数  如果要改动 把substring 最后一位数改动就可
    }
    //处理监听扫码枪
    //queryDataFlg=self.setInterval("querySupply_Mterial()",9000);
</script>
</html>